from django.db import migrations

def insert_province_data(apps, schema_editor):
    ProvincePatent = apps.get_model('trend', 'ProvincePatent')
    
    # 省份专利数据
    province_data = {
        "北京市": 12500,
        "上海市": 10800,
        "广东省": 15000,
        "江苏省": 13200,
        "浙江省": 9800,
        "山东省": 7500,
        "四川省": 6200,
        "湖北省": 5800,
        "陕西省": 4500,
        "天津市": 4200,
        "重庆市": 3800,
        "河北省": 3500,
        "福建省": 3200,
        "湖南省": 3000,
        "安徽省": 2800,
        "辽宁省": 2500,
        "江西省": 2200,
        "云南省": 2000,
        "贵州省": 1800,
        "广西壮族自治区": 1500,
        "河南省": 3300,
        "山西省": 2100,
        "内蒙古自治区": 1600,
        "黑龙江省": 1900,
        "吉林省": 1700,
        "新疆维吾尔自治区": 1400,
        "甘肃省": 1300,
        "宁夏回族自治区": 1100,
        "青海省": 900,
        "西藏自治区": 800,
        "海南省": 1200,
        "香港特别行政区": 2500,
        "澳门特别行政区": 1800
    }
    
    # 批量创建数据
    for province, count in province_data.items():
        ProvincePatent.objects.create(
            province=province,
            count=count
        )

class Migration(migrations.Migration):
    dependencies = [
        ('trend', '01_initial'),
    ]
    
    operations = [
        migrations.RunPython(insert_province_data),
    ] 